3.5.26 \(\int \tan ^2(c+d x) (a+b \tan (c+d x))^2 \, dx\) [426]

Optimal. Leaf size=63 \[ -\left (\left (a^2-b^2\right ) x\right )+\frac {2 a b \log (\cos (c+d x))}{d}-\frac {b^2 \tan (c+d x)}{d}+\frac {(a+b \tan (c+d x))^3}{3 b d} \]

[Out]

-(a^2-b^2)*x+2*a*b*ln(cos(d*x+c))/d-b^2*tan(d*x+c)/d+1/3*(a+b*tan(d*x+c))^3/b/d

________________________________________________________________________________________

Rubi [A]
time = 0.04, antiderivative size = 63, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {3624, 3558, 3556} \begin {gather*} -x \left (a^2-b^2\right )+\frac {(a+b \tan (c+d x))^3}{3 b d}+\frac {2 a b \log (\cos (c+d x))}{d}-\frac {b^2 \tan (c+d x)}{d} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[Tan[c + d*x]^2*(a + b*Tan[c + d*x])^2,x]

[Out]

-((a^2 - b^2)*x) + (2*a*b*Log[Cos[c + d*x]])/d - (b^2*Tan[c + d*x])/d + (a + b*Tan[c + d*x])^3/(3*b*d)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3558

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^2, x_Symbol] :> Simp[(a^2 - b^2)*x, x] + (Dist[2*a*b, Int[Tan[c + d
*x], x], x] + Simp[b^2*(Tan[c + d*x]/d), x]) /; FreeQ[{a, b, c, d}, x]

Rule 3624

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^2, x_Symbol] :> Simp[
d^2*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e + f*x])^m*Simp[c^2 - d^2 + 2*c*d*Tan[e
 + f*x], x], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && NeQ[b*c - a*d, 0] &&  !LeQ[m, -1] &&  !(EqQ[m, 2] && EqQ
[a, 0])

Rubi steps

\begin {align*} \int \tan ^2(c+d x) (a+b \tan (c+d x))^2 \, dx &=\frac {(a+b \tan (c+d x))^3}{3 b d}-\int (a+b \tan (c+d x))^2 \, dx\\ &=-\left (a^2-b^2\right ) x-\frac {b^2 \tan (c+d x)}{d}+\frac {(a+b \tan (c+d x))^3}{3 b d}-(2 a b) \int \tan (c+d x) \, dx\\ &=-\left (a^2-b^2\right ) x+\frac {2 a b \log (\cos (c+d x))}{d}-\frac {b^2 \tan (c+d x)}{d}+\frac {(a+b \tan (c+d x))^3}{3 b d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.32, size = 99, normalized size = 1.57 \begin {gather*} -\frac {a^2 \text {ArcTan}(\tan (c+d x))}{d}+\frac {b^2 \text {ArcTan}(\tan (c+d x))}{d}+\frac {a^2 \tan (c+d x)}{d}-\frac {b^2 \tan (c+d x)}{d}+\frac {b^2 \tan ^3(c+d x)}{3 d}+\frac {a b \left (2 \log (\cos (c+d x))+\tan ^2(c+d x)\right )}{d} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[Tan[c + d*x]^2*(a + b*Tan[c + d*x])^2,x]

[Out]

-((a^2*ArcTan[Tan[c + d*x]])/d) + (b^2*ArcTan[Tan[c + d*x]])/d + (a^2*Tan[c + d*x])/d - (b^2*Tan[c + d*x])/d +
 (b^2*Tan[c + d*x]^3)/(3*d) + (a*b*(2*Log[Cos[c + d*x]] + Tan[c + d*x]^2))/d

________________________________________________________________________________________

Maple [A]
time = 0.03, size = 83, normalized size = 1.32

method result size
norman \(\left (-a^{2}+b^{2}\right ) x +\frac {\left (a^{2}-b^{2}\right ) \tan \left (d x +c \right )}{d}+\frac {a b \left (\tan ^{2}\left (d x +c \right )\right )}{d}+\frac {b^{2} \left (\tan ^{3}\left (d x +c \right )\right )}{3 d}-\frac {a b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{d}\) \(80\)
derivativedivides \(\frac {\frac {b^{2} \left (\tan ^{3}\left (d x +c \right )\right )}{3}+a b \left (\tan ^{2}\left (d x +c \right )\right )+a^{2} \tan \left (d x +c \right )-b^{2} \tan \left (d x +c \right )-a b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )+\left (-a^{2}+b^{2}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(83\)
default \(\frac {\frac {b^{2} \left (\tan ^{3}\left (d x +c \right )\right )}{3}+a b \left (\tan ^{2}\left (d x +c \right )\right )+a^{2} \tan \left (d x +c \right )-b^{2} \tan \left (d x +c \right )-a b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )+\left (-a^{2}+b^{2}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(83\)
risch \(-2 i a b x -a^{2} x +b^{2} x -\frac {4 i a b c}{d}+\frac {2 i \left (-6 i a b \,{\mathrm e}^{4 i \left (d x +c \right )}+3 a^{2} {\mathrm e}^{4 i \left (d x +c \right )}-6 b^{2} {\mathrm e}^{4 i \left (d x +c \right )}-6 i a b \,{\mathrm e}^{2 i \left (d x +c \right )}+6 a^{2} {\mathrm e}^{2 i \left (d x +c \right )}-6 b^{2} {\mathrm e}^{2 i \left (d x +c \right )}+3 a^{2}-4 b^{2}\right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{3}}+\frac {2 a b \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{d}\) \(161\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(tan(d*x+c)^2*(a+b*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(1/3*b^2*tan(d*x+c)^3+a*b*tan(d*x+c)^2+a^2*tan(d*x+c)-b^2*tan(d*x+c)-a*b*ln(1+tan(d*x+c)^2)+(-a^2+b^2)*arc
tan(tan(d*x+c)))

________________________________________________________________________________________

Maxima [A]
time = 0.51, size = 78, normalized size = 1.24 \begin {gather*} \frac {b^{2} \tan \left (d x + c\right )^{3} + 3 \, a b \tan \left (d x + c\right )^{2} - 3 \, a b \log \left (\tan \left (d x + c\right )^{2} + 1\right ) - 3 \, {\left (a^{2} - b^{2}\right )} {\left (d x + c\right )} + 3 \, {\left (a^{2} - b^{2}\right )} \tan \left (d x + c\right )}{3 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2*(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

1/3*(b^2*tan(d*x + c)^3 + 3*a*b*tan(d*x + c)^2 - 3*a*b*log(tan(d*x + c)^2 + 1) - 3*(a^2 - b^2)*(d*x + c) + 3*(
a^2 - b^2)*tan(d*x + c))/d

________________________________________________________________________________________

Fricas [A]
time = 0.88, size = 77, normalized size = 1.22 \begin {gather*} \frac {b^{2} \tan \left (d x + c\right )^{3} + 3 \, a b \tan \left (d x + c\right )^{2} - 3 \, {\left (a^{2} - b^{2}\right )} d x + 3 \, a b \log \left (\frac {1}{\tan \left (d x + c\right )^{2} + 1}\right ) + 3 \, {\left (a^{2} - b^{2}\right )} \tan \left (d x + c\right )}{3 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2*(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

1/3*(b^2*tan(d*x + c)^3 + 3*a*b*tan(d*x + c)^2 - 3*(a^2 - b^2)*d*x + 3*a*b*log(1/(tan(d*x + c)^2 + 1)) + 3*(a^
2 - b^2)*tan(d*x + c))/d

________________________________________________________________________________________

Sympy [A]
time = 0.11, size = 94, normalized size = 1.49 \begin {gather*} \begin {cases} - a^{2} x + \frac {a^{2} \tan {\left (c + d x \right )}}{d} - \frac {a b \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{d} + \frac {a b \tan ^{2}{\left (c + d x \right )}}{d} + b^{2} x + \frac {b^{2} \tan ^{3}{\left (c + d x \right )}}{3 d} - \frac {b^{2} \tan {\left (c + d x \right )}}{d} & \text {for}\: d \neq 0 \\x \left (a + b \tan {\left (c \right )}\right )^{2} \tan ^{2}{\left (c \right )} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)**2*(a+b*tan(d*x+c))**2,x)

[Out]

Piecewise((-a**2*x + a**2*tan(c + d*x)/d - a*b*log(tan(c + d*x)**2 + 1)/d + a*b*tan(c + d*x)**2/d + b**2*x + b
**2*tan(c + d*x)**3/(3*d) - b**2*tan(c + d*x)/d, Ne(d, 0)), (x*(a + b*tan(c))**2*tan(c)**2, True))

________________________________________________________________________________________

Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 675 vs. \(2 (61) = 122\).
time = 0.97, size = 675, normalized size = 10.71 \begin {gather*} -\frac {3 \, a^{2} d x \tan \left (d x\right )^{3} \tan \left (c\right )^{3} - 3 \, b^{2} d x \tan \left (d x\right )^{3} \tan \left (c\right )^{3} - 3 \, a b \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{4} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right )^{3} \tan \left (c\right ) + \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right )^{3} \tan \left (c\right )^{3} - 9 \, a^{2} d x \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + 9 \, b^{2} d x \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 3 \, a b \tan \left (d x\right )^{3} \tan \left (c\right )^{3} + 9 \, a b \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{4} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right )^{3} \tan \left (c\right ) + \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + 3 \, a^{2} \tan \left (d x\right )^{3} \tan \left (c\right )^{2} - 3 \, b^{2} \tan \left (d x\right )^{3} \tan \left (c\right )^{2} + 3 \, a^{2} \tan \left (d x\right )^{2} \tan \left (c\right )^{3} - 3 \, b^{2} \tan \left (d x\right )^{2} \tan \left (c\right )^{3} + 9 \, a^{2} d x \tan \left (d x\right ) \tan \left (c\right ) - 9 \, b^{2} d x \tan \left (d x\right ) \tan \left (c\right ) - 3 \, a b \tan \left (d x\right )^{3} \tan \left (c\right ) + 3 \, a b \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - 3 \, a b \tan \left (d x\right ) \tan \left (c\right )^{3} + b^{2} \tan \left (d x\right )^{3} - 9 \, a b \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{4} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right )^{3} \tan \left (c\right ) + \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (c\right )^{2} + 1}\right ) \tan \left (d x\right ) \tan \left (c\right ) - 6 \, a^{2} \tan \left (d x\right )^{2} \tan \left (c\right ) + 9 \, b^{2} \tan \left (d x\right )^{2} \tan \left (c\right ) - 6 \, a^{2} \tan \left (d x\right ) \tan \left (c\right )^{2} + 9 \, b^{2} \tan \left (d x\right ) \tan \left (c\right )^{2} + b^{2} \tan \left (c\right )^{3} - 3 \, a^{2} d x + 3 \, b^{2} d x + 3 \, a b \tan \left (d x\right )^{2} - 3 \, a b \tan \left (d x\right ) \tan \left (c\right ) + 3 \, a b \tan \left (c\right )^{2} + 3 \, a b \log \left (\frac {4 \, {\left (\tan \left (d x\right )^{4} \tan \left (c\right )^{2} - 2 \, \tan \left (d x\right )^{3} \tan \left (c\right ) + \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + \tan \left (d x\right )^{2} - 2 \, \tan \left (d x\right ) \tan \left (c\right ) + 1\right )}}{\tan \left (c\right )^{2} + 1}\right ) + 3 \, a^{2} \tan \left (d x\right ) - 3 \, b^{2} \tan \left (d x\right ) + 3 \, a^{2} \tan \left (c\right ) - 3 \, b^{2} \tan \left (c\right ) + 3 \, a b}{3 \, {\left (d \tan \left (d x\right )^{3} \tan \left (c\right )^{3} - 3 \, d \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + 3 \, d \tan \left (d x\right ) \tan \left (c\right ) - d\right )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2*(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

-1/3*(3*a^2*d*x*tan(d*x)^3*tan(c)^3 - 3*b^2*d*x*tan(d*x)^3*tan(c)^3 - 3*a*b*log(4*(tan(d*x)^4*tan(c)^2 - 2*tan
(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(c)^2 + 1))*tan(d*x)^3*tan(c)^3
 - 9*a^2*d*x*tan(d*x)^2*tan(c)^2 + 9*b^2*d*x*tan(d*x)^2*tan(c)^2 - 3*a*b*tan(d*x)^3*tan(c)^3 + 9*a*b*log(4*(ta
n(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(c)^2
+ 1))*tan(d*x)^2*tan(c)^2 + 3*a^2*tan(d*x)^3*tan(c)^2 - 3*b^2*tan(d*x)^3*tan(c)^2 + 3*a^2*tan(d*x)^2*tan(c)^3
- 3*b^2*tan(d*x)^2*tan(c)^3 + 9*a^2*d*x*tan(d*x)*tan(c) - 9*b^2*d*x*tan(d*x)*tan(c) - 3*a*b*tan(d*x)^3*tan(c)
+ 3*a*b*tan(d*x)^2*tan(c)^2 - 3*a*b*tan(d*x)*tan(c)^3 + b^2*tan(d*x)^3 - 9*a*b*log(4*(tan(d*x)^4*tan(c)^2 - 2*
tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(c)^2 + 1))*tan(d*x)*tan(c)
- 6*a^2*tan(d*x)^2*tan(c) + 9*b^2*tan(d*x)^2*tan(c) - 6*a^2*tan(d*x)*tan(c)^2 + 9*b^2*tan(d*x)*tan(c)^2 + b^2*
tan(c)^3 - 3*a^2*d*x + 3*b^2*d*x + 3*a*b*tan(d*x)^2 - 3*a*b*tan(d*x)*tan(c) + 3*a*b*tan(c)^2 + 3*a*b*log(4*(ta
n(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(c)^2
+ 1)) + 3*a^2*tan(d*x) - 3*b^2*tan(d*x) + 3*a^2*tan(c) - 3*b^2*tan(c) + 3*a*b)/(d*tan(d*x)^3*tan(c)^3 - 3*d*ta
n(d*x)^2*tan(c)^2 + 3*d*tan(d*x)*tan(c) - d)

________________________________________________________________________________________

Mupad [B]
time = 4.07, size = 108, normalized size = 1.71 \begin {gather*} \frac {b^2\,{\mathrm {tan}\left (c+d\,x\right )}^3}{3\,d}+\frac {\mathrm {tan}\left (c+d\,x\right )\,\left (a^2-b^2\right )}{d}-\frac {\mathrm {atan}\left (\frac {\mathrm {tan}\left (c+d\,x\right )\,\left (a+b\right )\,\left (a-b\right )}{a^2-b^2}\right )\,\left (a+b\right )\,\left (a-b\right )}{d}-\frac {a\,b\,\ln \left ({\mathrm {tan}\left (c+d\,x\right )}^2+1\right )}{d}+\frac {a\,b\,{\mathrm {tan}\left (c+d\,x\right )}^2}{d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(tan(c + d*x)^2*(a + b*tan(c + d*x))^2,x)

[Out]

(b^2*tan(c + d*x)^3)/(3*d) + (tan(c + d*x)*(a^2 - b^2))/d - (atan((tan(c + d*x)*(a + b)*(a - b))/(a^2 - b^2))*
(a + b)*(a - b))/d - (a*b*log(tan(c + d*x)^2 + 1))/d + (a*b*tan(c + d*x)^2)/d

________________________________________________________________________________________